using UnityEngine;
using System.Collections;

public class BasicWindowGui : MonoBehaviour {
	/**
	 * Rectangle representing the current window appearance
	 */
	private Rect WindowRect;
	
	public string title = "Put-Title-Here";
	
	/* locally or globally unique? some TODO here */
	private int WindowID = 1;
	
	void Start () {
		/* Arbitrary, probably pull from some constant */
		this.WindowRect = new Rect(150,30,200,320);
	}
	
	void OnGUI () {
		this.WindowRect = GUI.Window (this.WindowID, this.WindowRect, WindowFunc, this.title);
	}
	
	/* TODO: Observer pattern */
	void NotifyListeners() {
	}
	
	void DestroySelf() {
		this.NotifyListeners();
		Destroy (this);
	}
	
	void WindowFunc(int id) {
		Rect CloseButtonRect;
		bool close;
		
		CloseButtonRect = new Rect(
			this.WindowRect.width * 0.125f,
			this.WindowRect.height * 0.75f,
			this.WindowRect.width * 0.75f,
			this.WindowRect.height * 0.2f);
		
		close = GUI.Button(CloseButtonRect, "Close");
		if (close) {
			this.DestroySelf();
			return;
		}
		
		GUI.DragWindow();
	}
}
